//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.example.app.util;

import org.springframework.util.StringUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class TimeHelper {
    public TimeHelper() {
    }

    public static long getCurrentTimes() {
        return (new Date()).getTime();
    }

    public static Date getCurrentDate() {
        return new Date();
    }

    public static String getCurrentTime() {
        return (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date());
    }

    public static String getCurrentDate(String outFormat) {
        if (StringUtils.isEmpty(outFormat)) {
            outFormat = "yyyy-MM-dd HH:mm:ss";
        }

        return (new SimpleDateFormat(outFormat)).format(new Date());
    }

    public static Date getDate(String date, String inFormat) {
        try {
            return (new SimpleDateFormat(inFormat)).parse(date);
        } catch (ParseException var3) {
            var3.printStackTrace();
            return null;
        }
    }

    public static String getDate(String date, String inFormat, String outFormat) {
        try {
            return (new SimpleDateFormat(outFormat)).format((new SimpleDateFormat(inFormat)).parse(date));
        } catch (ParseException var4) {
            var4.printStackTrace();
            return null;
        }
    }

    public static String getDate(Date date, String outFormat) {
        return (new SimpleDateFormat(outFormat)).format(date);
    }

    public static int compareDate(String d, String d2) {
        try {
            String format = "yyyyMMddHHmmss";
            String fillZero = "00000000000000";
            d = d.replace(" ", "").replace("-", "").replace(":", "");
            Date date = (new SimpleDateFormat(format)).parse(d + fillZero.substring(d.length()));
            d2 = d2.replace(" ", "").replace("-", "").replace(":", "");
            Date date2 = (new SimpleDateFormat(format)).parse(d2 + fillZero.substring(d2.length()));
            return compareDate(date, date2);
        } catch (ParseException var6) {
            var6.printStackTrace();
            return -2147483648;
        }
    }

    public static int compareDate(Date d, Date d2) {
        if (d.getTime() == d2.getTime()) {
            return 0;
        } else {
            return d.getTime() > d2.getTime() ? 1 : -1;
        }
    }

    public static Date plus(String date, int year, int month, int day, int hours, int minutes, int seconds) {
        try {
            String format = "yyyyMMddHHmmss";
            String fillZero = "00000000000000";
            date = date.replace(" ", "").replace("-", "").replace(":", "");
            date = date + fillZero.substring(date.length());
            Date dt = (new SimpleDateFormat(format)).parse(date);
            return plus(dt, year, month, day, hours, minutes, seconds);
        } catch (ParseException var10) {
            return null;
        }
    }

    public static Date plus(Date date, int year, int month, int day, int hours, int minutes, int seconds) {
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        calendar.set(1, year);
        calendar.set(2, month);
        calendar.set(5, day);
        calendar.set(10, hours);
        calendar.set(12, minutes);
        calendar.set(13, seconds);
        return calendar.getTime();
    }

    public static int minus(String d, String d2) {
        String format = "yyyyMMddHHmmss";
        String fillZero = "00000000000000";
        d = d.replace(" ", "").replace("-", "").replace(":", "");
        d = d + fillZero.substring(d.length());
        d2 = d2.replace(" ", "").replace("-", "").replace(":", "");
        d2 = d2 + fillZero.substring(d2.length());

        try {
            Date date = (new SimpleDateFormat(format)).parse(d);
            Date date2 = (new SimpleDateFormat(format)).parse(d2);
            return minus(date, date2);
        } catch (ParseException var6) {
            var6.printStackTrace();
            return 0;
        }
    }

    public static int minus(Date d, Date d2) {
        long c = d.getTime() - d2.getTime();
        return (int)c;
    }
}
